<?php

namespace km\util;

/**
 * RefBook
 *
 * @author vbolshov
 */
abstract class RefBook {
	/**
	 * @var string[]
	 */
	private $map, $mapFlipped;

	final function __construct(array $map)
	{
		$this->map = $map;
		$this->mapFlipped = array_flip($map);
	}

	abstract protected function createMap();

	final function getString($key)
	{
		return $this->map[$key];
	}

	final function getKey($string)
	{
		return $this->mapFlipped[$string];
	}

	final function export()
	{
		return $this->map;
	}
}